package cn.fengshenghospital.controller;

import cn.fengshenghospital.entity.Experts;
import cn.fengshenghospital.service.ExpertsService;
import cn.fengshenghospital.vo.JsonBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/experts")
public class ExpertsController {

    @Autowired
    private ExpertsService expertsService;
    @GetMapping("/queryExpertsByName")
    public JsonBean queryExpertsByName( String experName, int page){
        JsonBean jsonBean=new JsonBean("queryExpertsByName");
        try {
            List<Experts> list= expertsService.queryExpertsByName(experName,page);
            Map<String,Object> map=new HashMap<String,Object>();
            map.put("list",list);
            map.put("page",page);
            map.put("pageCount",expertsService.queryPage(experName,"experName"));
            jsonBean.setData(map);
            jsonBean.setStatus(200);
        }catch (Exception e){
            jsonBean.setStatus(-1);
        }
        return jsonBean;
    }
    @GetMapping("/queryExpertsBySid")
    public JsonBean queryExpertsBySid( int sid, int page){
        JsonBean jsonBean=new JsonBean("queryExpertsBySid");
        try {
            List<Experts> list= expertsService.queryExpertsBySid(sid,page);
            Map<String,Object> map=new HashMap<String,Object>();
            map.put("list",list);
            map.put("pageCount",expertsService.queryPage(sid+"","sid"));
            map.put("page",page);
            jsonBean.setData(map);
            jsonBean.setStatus(200);
        }catch (Exception e){
            jsonBean.setStatus(-1);
        }
        return jsonBean;
    }
    @GetMapping("/queryExpertsInfoById")
    public JsonBean queryExpertsInfoById(int eId){
        JsonBean jsonBean=new JsonBean("queryExpertsInfoById");
        try {
            Experts experts=expertsService.queryExpertsInfoById(eId);
            jsonBean.setData(experts);
            jsonBean.setStatus(200);
        }catch (Exception e){
            jsonBean.setStatus(-1);
        }
        return jsonBean;
    }
    @GetMapping("/querySectionInfoBySid")
    public JsonBean querySectionInfoBySid(int sId){
        return null;
    }
}
